<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${question.title}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="/css/czmblog.css"/>
    <link rel="stylesheet" href="/css/editormd.preview.min.css">
    <script src="/js/jquery-3.4.1.min.js"></script>
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="/js/czmblog.js"></script>
    <script src="/js/moment.js"></script>
    <script src="/js/editormd.min.js"></script>
    <script src="/js/marked.min.js"></script>
    <script src="/js/prettify.min.js"></script>
</head>
<body>
<div th:insert="~{navigaction :: nav}"></div>
<div class="container-fluid main profile">
    <div class="row">
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
            <!--问题内容-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <h3 class="question-title"><span th:text="${question.title}"></span></h3>
                    <span class="text-desc">
                    作者：<span th:text="${question.user.name}"></span>&nbsp;|
                    发布于<span th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>&nbsp;|
                    <span th:text="${question.viewCount}"></span>次浏览</span>
                    <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <!--内容-->
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="question-view">
                        <textarea style="display:none;" th:text="${question.description}"></textarea>
                    </div>
                    <script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
                    <script type="text/javascript">
                        $(function () {
                            editormd.markdownToHTML("question-view", {});
                        });
                    </script>
                    <!--标签-->
                    <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <span class="label label-info question-tag" th:each="tag : ${question.tag.split(',')}">
                            <span class="glyphicon glyphicon-tag"></span>
                            <span th:text="${tag}"></span>
                        </span>
                    </span>
                    </div>
                    <!--编辑-->
                    <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <a th:href="@{'/publish/'+${question.id}}" class="community-menu" th:if="${session.user != null && session.user.id == question.creator}">
                            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>编辑
                        </a>
                    </div>
                    <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12" >
                </div>
            </div>
            <!--回复-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4><span class="badge" th:text="${question.commentCount}"></span>个评论</h4>
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-section" th:each="comment : ${comments}">
                    <div class="media">
                        <div class="media-left">
                            <img class="media-object img-wh img-thumbnail" th:src="${comment.user.avatarUrl}">
                        </div>
                        <div class="media-body">
                            <span class="media-heading" th:text="${comment.user.name}"></span>：
                            <div th:text="${comment.content}"></div>
                        </div>
                        <div class="menu">
                            <span class="glyphicon glyphicon-thumbs-up icon"></span>
                            <!--<span class="glyphicon glyphicon-comment icon" th:data-id="${comment.id}" onclick="collapseComments(this)">
                                <span class="badge" th:text="${comment.commentCount}"></span>
                            </span>-->
                            <button class="btn btn-primary" type="button" th:data-id="${comment.id}" onclick="collapseComments(this)">
                                评论<span class="badge" th:text="${comment.commentCount}"></span>
                            </button>
                            <span th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>
                        </div>

                        <!--二级评论-->
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 collapse"
                             th:id="${'comment-'+comment.id}">

                            <!--<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 ">
                                <ul class="list-group">
                                    <li class="list-group-item">
                                        <div class="media">
                                            <div class="media-left">
                                                <img class="media-object img-thumbnail img-wh" th:src="${comment.user.avatarUrl}">
                                            </div>
                                            <div class="media-body">
                                                <div>
                                                    <span th:text="${comment.user.name}+'：'"></span>
                                                    <span th:text="${comment.content}"></span>
                                                    <span th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>
                                                </div>
                                            </div>
                                        </div>

                                    </li>
                                </ul>
                            </div>-->

                            <!--<div class="menu">
                                <span class="icon" th:data-id="${comment.id}" onclick="collapseComments(this)">回复</span>
                            </div>-->
                            <!--二级评论的回复框-->
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment2-btn">
                                <input type="text" class="form-control" placeholder="评论一下……" th:id="${'input-'+comment.id}">
                                <button type="button" class="btn btn-success pull-right" onclick="comment(this)" th:data-id="${comment.id}">评论
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--回复输入-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>提交回复</h4>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="comment_section">
                    <div>
                        <div class="media-left">
                            <img class="media-object img-wh img-thumbnail" th:src="${session.user != null ? session.user.avatarUrl : '/images/default-avatar.png'}">
                        </div>
                        <div class="media-body" style="padding-top: 20px;">
                            <h5 class="media-heading">
                                <span th:text="${session.user != null ? session.user.name : '匿名用户'}"></span>
                            </h5>
                            </span>
                        </div>
                    </div>
                    <input type="hidden" id="question_id" th:value="${question.id}">
                    <textarea class="form-control comment" rows="6" id="comment_context"></textarea>
                    <button type="button" class="btn btn-success btn-comment" onclick="question()">发布评论</button>
                </div>
            </div>

        </div>
        <!--右边-->
        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3>发起人</h3>
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-wh img-thumbnail" th:src="${question.user.avatarUrl}">
                        </a>
                    </div>
                    <div class="media-body">
                        <h5 class="media-heading">
                            <span th:text="${question.user.name}"></span>
                        </h5>
                        </span>
                    </div>
                </div>
            </div>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div th:insert="~{notice :: notice}"></div>
            <!--<div th:insert="~{notice :: notice}"></div>-->
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3>相关问题</h3>
                <ul class="question-related">
                    <li th:each="related : ${relatedQuestions}">
                        <a class="q-fontsize" th:href="@{'/question/'+ ${related.id}}" th:text="${related.title}"></a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<div th:insert="~{footer :: foot}"></div>
</body>
</html>